#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
/* I will realize a single linked list.To review the
data structure*/
typedef struct node{
    int data;
    struct node* next;
} node,* list;

void print(list *L){
    node* p=(*L)->next;
    while(p!=NULL){
        printf("%d\n",p->data);
        p=p->next;
    }
}
bool init_list(list *L){
    *L=(node*)malloc(sizeof(node));
    if((*L)!=NULL){
        (*L)->next=NULL;
        return true;
    }
    else return false;
}

bool rankInsert(list *L,int i,int e){
    if(i<1){
        printf("ERROR\n");
        return false;
    }
    //node *p=(node*)malloc(sizeof(node));
    node *p=*L;
    int j=0;
    while(p->next!=NULL && j<i-1){
        p=p->next;
        j++;
    }
    if(p==NULL){
        printf("ERROR");
        return false;
    }
    node *s=(node*)malloc(sizeof(node));
    s->data=e;
    s->next=p->next;
    p->next=s;
    return true;
}


int main(){
    list L;
    init_list(&L);
    for(int i=1;i<=10;i++)
        rankInsert(&L,i,i);
    
    print(&L);
}